import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';
import 'package:xinxuan/common/culling_goods_arr.dart';
import 'package:xinxuan/common/home_bottom_clipper.dart';
import 'package:xinxuan/common/network_image_util.dart';
import 'package:xinxuan/common/scroll_configuration_common.dart';
import 'package:xinxuan/common/swiper_util.dart';
import 'package:xinxuan/controllers/common_page_controller.dart';
import 'package:xinxuan/controllers/cooperation_controller/cooperation_page_controller.dart';
import 'package:xinxuan/controllers/home_controller/home_page_controller.dart';
import 'package:xinxuan/router/app_routers.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:get/get.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:xinxuan/utils/refresh_util.dart';
import 'package:xinxuan/vo/activities_list_vo.dart';
import 'package:xinxuan/vo/categoires_list_vo.dart';
import 'package:xinxuan/vo/features_list_vo.dart';
import 'package:xinxuan/vo/promises_list_vo.dart';

class HomePage extends StatelessWidget {

  final HomePageController controller = Get.put(HomePageController());
  final CommonPageController commonPageController = Get.find();

  @override
  Widget build(BuildContext context) {
    // return Scaffold(
    //   backgroundColor: pageBgColor,
    //   body: GetBuilder<HomePageController>(
    //     builder: (controller) {
    //       return Stack(
    //         children: [
    //           Stack(
    //             children: [
    //               _arcBackground(controller),
    //               Positioned(
    //                 child: Column(
    //                   children: [
    //                     _searchBar(),
    //                     Expanded(child: ScrollConfigurationCommon(child: 
    //                     RefreshUtil.easyRefresh(
    //                       scrollController: controller.scrollController,
    //                       onRefresh: () async {
    //                         controller.initPageDate();
    //                       },
    //                       onLoad: () async {
    //                         controller.onloadFeaturesList();
    //                       },
    //                       slivers: [
    //                         SliverToBoxAdapter(
    //                           child: _selectGoodThingsIconBody(controller),
    //                         ),
    //                         SliverToBoxAdapter(
    //                           child: SwiperUtil(
    //                           images: controller.bannerArr, 
    //                           width: 350.w, 
    //                           height: 122.h, 
    //                           borderRadius: 8.w, 
    //                           padding: 12.w
    //                         ),
    //                         ),
    //                         SliverToBoxAdapter(
    //                           child: _kingGangBody(controller),
    //                         ),
    //                         SliverToBoxAdapter(
    //                           child: _newsBody(controller),
    //                         ),
    //                         SliverToBoxAdapter(
    //                           child: _activityBody(controller),
    //                         ),
    //                         SliverToBoxAdapter(
    //                           child: _goodThings(controller),
    //                         ),
    //                         SliverToBoxAdapter(
    //                           child: SizedBox(height: 32.h),
    //                         ),
    //                       ]
    //                     )))
    //                   ],
    //                 )
    //               )
    //             ],
    //           ),
    //           Positioned(
    //             right: 0,
    //             bottom: 0,
    //             top: 0,
    //             child: Container(
    //               width: 90.w,
    //               height: 90.w,
    //               alignment: Alignment.center,
    //               child: InkWellUtil.shakeProofInkWell(Image.asset(
    //                 'assets/icons/icon_activity.png',
    //                 width: 90.w,
    //                 height: 90.w,
    //               ), () {
    //                 // Get.toNamed('${AppRouters.COMMON_PAGE}${AppRouters.ACTIVTY_PAGE}');
    //                 commonPageController.tabIndex.value = 1;
    //               }),
    //             )
    //           )
    //         ],
    //       );
    //     },
    //   ),
    // );
    return Scaffold(
      backgroundColor: pageBgColor,
      body: GetBuilder<HomePageController>(
        builder: (controller) {
          return Stack(
            children: [
              ScrollConfigurationCommon(child: 
                RefreshUtil.easyRefresh(
                  // scrollController: controller.scrollController,
                  // onRefresh: () async {
                  //   controller.initPageDate();
                  // },
                  onLoad: () async {
                    controller.onloadFeaturesList();
                  },
                  slivers: [
                    SliverToBoxAdapter(
                      child: Stack(
                        children: [
                          _arcBackground(controller),
                          Column(
                            children: [
                              Container(
                                height: 44.h + ScreenUtil().statusBarHeight,
                              ),
                              _selectGoodThingsIconBody(controller),
                              SwiperUtil(
                                images: controller.bannerArr, 
                                width: 350.w, 
                                height: 122.h, 
                                borderRadius: 8.w, 
                                padding: 12.w
                              )
                            ],
                          ),
                        ],
                      ),
                    ),
                    SliverToBoxAdapter(
                      child: _kingGangBody(controller),
                    ),
                    SliverToBoxAdapter(
                      child: _newsBody(controller),
                    ),
                    SliverToBoxAdapter(
                      child: _activityBody(controller),
                    ),
                    SliverToBoxAdapter(
                      child: _goodThings(controller),
                    ),
                    SliverToBoxAdapter(
                      child: SizedBox(height: 32.h),
                    ),
                  ]
                )
              ),
              Obx(() => Positioned(
                right: 0,
                left: null,
                bottom: null,
                top: controller.activityDy.value,
                child: Container(
                  width: 90.w,
                  height: 90.w,
                  alignment: Alignment.center,
                  child: InkWellUtil.shakeProofInkWell(Draggable(
                    child: Image.asset(
                      'assets/icons/icon_activity.png',
                      width: 90.w,
                      height: 90.w,
                    ), 
                    // feedback: Image.asset(
                    //   'assets/icons/icon_activity.png',
                    //   width: 90.w,
                    //   height: 90.w,
                    // ),
                    feedback: Container(),
                    onDragUpdate: (detial) {
                      if (detial.localPosition.dy <= 100.h) {
                        controller.activityDy.value = 100.h;
                        return;
                      } else if (detial.localPosition.dy >= 612.h) {
                        controller.activityDy.value = 612.h;
                        return;
                      }
                      controller.activityDy.value = detial.localPosition.dy;
                    },
                    // onDragEnd: (detial) {
                    //   if (detial.offset.dy <= 100.h) {
                    //     controller.activityDy.value = 100.h;
                    //     return;
                    //   } else if (detial.offset.dy >= 612.h) {
                    //     controller.activityDy.value = 612.h;
                    //     return;
                    //   }
                    //   controller.activityDy.value = detial.offset.dy;
                    // },
                    ), () {
                    commonPageController.tabIndex.value = 1;
                  }),
                )
              )),
              Positioned(
                child: _searchBar(),
              )
            ],
          );
        },
      ),
    );
  }

  /// 圆弧背景
  Widget _arcBackground(HomePageController controller) {
    // return Obx(() => ClipPath(
    //   clipper: HomeBottomClipper(subHeight: controller.subHeight.value),
    //   clipper: HomeBottomClipper(subHeight: 230.h),
    //   child: Container(
    //     height: 230.h - controller.subHeight.value,
    //     height: 230.h,
    //     decoration: BoxDecoration(
    //       gradient: LinearGradient(
    //         begin: Alignment.centerLeft,
    //         end: Alignment.centerRight,
    //         colors: [
    //           bgMainColor,
    //           bgExcessiveColor
    //         ]
    //       )
    //     ),
    //   ),
    // ));
    return ClipPath(
      clipper: HomeBottomClipper(subHeight: 0),
      child: Container(
        height: 230.h,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.centerLeft,
            end: Alignment.centerRight,
            colors: [
              bgMainColor,
              bgExcessiveColor
            ]
          )
        ),
      ),
    );
  }

  /// 搜索栏目
  Widget _searchBar() {
    return Container(
      height: 44.h + ScreenUtil().statusBarHeight,
      width: 375.w,
      padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight),
      decoration: BoxDecoration(
        gradient: LinearGradient(
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
          colors: [
            bgMainColor,
            bgExcessiveColor
          ]
        )
      ),
      child: Container(
        height: 44.h,
        padding: EdgeInsets.symmetric(horizontal: 28.w),
        child: Center(
          child: Row(
            children: [
              Expanded(child: InkWellUtil.shakeProofInkWell(Container(
                height: 32.h,
                padding: EdgeInsets.symmetric(horizontal: 10.w),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(42.w),
                  color: bgWhiteColor,
                ),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Image.asset(
                      'assets/icons/icon_search.png',
                      width: 18.w,
                      height: 18.w,
                    ),
                    SizedBox(width: 10.w),
                    Text(
                      '请您输入商品、品牌、店铺',
                      style: TextStyle(
                        color: tipsColor,
                        fontSize: 14.sp
                      ),
                    )
                  ],
                ),
              ), () {
                Get.toNamed('${AppRouters.COMMON_PAGE}${AppRouters.SEARCH_PAGE}');
              })),
              SizedBox(width: 12.w),
              GetBuilder<CommonPageController>(
                builder: (controller) {
                  return InkWellUtil.shakeProofInkWell(Image.asset(
                    'assets/icons/icon_notice.png',
                    width: 20.w,
                    height: 20.w,
                  ), () {
                    if (controller.isRevirew.value) {
                      controller.tabIndex.value = 1;
                    } else {
                      controller.tabIndex.value = 2;
                    }
                  });
                },
              )
            ],
          ),
        ),
      ),
    );
  }

  /// 精选好物 Icon
  Widget _selectGoodThingsIconBody(HomePageController controller) {
    List<PromisesItem> promisesArr = controller.promisesArr;
    return Container(
      padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 5.h, bottom: 11.h),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: promisesArr.map((item) {
          return _selectGoodThingsIconItem(item.image ?? '', item.title ?? '');
        }).toList(),
      ),
    );
  }

  /// 精选好物Item
  Widget _selectGoodThingsIconItem(String url, String title) {
    return Container(
      child: Row(
        children: [
          NetworkImageUtil(url: url, width: 22.w, height: 22.w),
          SizedBox(width: 2.w),
          Text(
            title,
            style: TextStyle(
              color: textWhiteColor,
              fontSize: 12.sp
            ),
          )
        ],
      ),
    );
  }

  /// 金刚区
  Widget _kingGangBody(HomePageController controller) {
    double height = 86.h;
    if (controller.categoiresArr.length >= 1) {
      if (controller.categoiresArr[0].length > 5) {
        height = 178.h;
      }
    }
    return Container(
      height: height,
      margin: EdgeInsets.symmetric(vertical: 12.h),
      child: controller.categoiresArr.length <= 0 ? Container() : Swiper(
        itemBuilder: (context, index) {
          List<CategoiresItem> arr = controller.categoiresArr[index];
          return Container(
            padding: EdgeInsets.symmetric(horizontal: 16.w),
            child: Wrap(
              spacing: 23.w,
              runSpacing: 20.h,
              children: arr.map((item) {
                return _kingGangItem(
                  item.id!,
                  item.image ?? '', 
                  item.title ?? ''
                );
              }).toList(),
            ),
          );
        }, 
        itemCount: controller.categoiresArr.length,
        loop: false,
        pagination: SwiperCustomPagination(
          builder: (BuildContext context, SwiperPluginConfig config) {
            return Container(
              alignment: Alignment.bottomCenter,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: controller.categoiresArr.asMap().keys.map((index) {
                  if (index == config.activeIndex) {
                    return Container(
                      width: 18.w,
                      height: 5.w,
                      margin: EdgeInsets.symmetric(horizontal: 3.w),
                      decoration: BoxDecoration(
                        color: mainTextColor,
                        borderRadius: BorderRadius.circular(5.w)
                      ),
                    );
                  } else {
                    return Container(
                      width: 13.w,
                      height: 5.w,
                      margin: EdgeInsets.symmetric(horizontal: 3.w),
                      decoration: BoxDecoration(
                        color: bgSubColor,
                        borderRadius: BorderRadius.circular(5.w)
                      ),
                    );
                  }
                }).toList()
              ),
            );
          }
        ),
      ),
    );
  }

  /// 金刚区Item
  Widget _kingGangItem(int id, String url, String title) {
    return InkWellUtil.shakeProofInkWell(Container(
      child: Column(
        children: [
          NetworkImageUtil(
            url: url, 
            width: 48.w, 
            height: 48.w,
          ),
          SizedBox(height: 6.h),
          Text(
            title,
            style: TextStyle(
              color: textBlackColor,
              fontSize: 12.sp
            ),
          )
        ],
      ),
    ), () {
      Get.toNamed(
        '${AppRouters.COMMON_PAGE}${AppRouters.SEARCH_PAGE}${AppRouters.SEARCH_RECORD_PAGE}',
        arguments: {
          'category_id': id,
          'title': title
        }
      );
    });
  }

  /// 公告
  Widget _newsBody(HomePageController controller) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      child: Container(
        height: 38.h,
        padding: EdgeInsets.symmetric(horizontal: 12.w),
        decoration: BoxDecoration(
          color: bgWhiteColor,
          borderRadius: BorderRadius.circular(20.w),
        ),
        child: Row(
          children: [
            Container(
              height: 38.h,
              padding: EdgeInsets.symmetric(horizontal: 6.w),
              decoration: BoxDecoration(
                border: Border(
                  right: BorderSide(
                    width: 1.w,
                    color: lineColor
                  )
                )
              ),
              child: Row(
                children: [
                  Image.asset(
                    'assets/icons/icon_ad.png',
                    width: 20.w,
                    height: 18.h,
                  ),
                  SizedBox(width: 6.w),
                  Image.asset(
                    'assets/icons/icon_notice_text.png',
                    width: 30.w,
                    height: 15.h,
                  ),
                ],
              ),
            ),
            Container(
              width: 250.w,
              height: 38.h,
              padding: EdgeInsets.only(left: 5.w),
              child: controller.newsArr.length <= 0 ? Container() : Swiper(
                scrollDirection: Axis.vertical,
                autoplay: true,
                itemBuilder: (context, index) {
                  return InkWellUtil.shakeProofInkWell(Container(
                    alignment: Alignment.centerLeft,
                    child: Text(
                      '${controller.newsArr[index].description}',
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                      style: TextStyle(
                        color: textBlackColor,
                        fontSize: 14.sp
                      ),
                    ),
                  ), () { 
                    controller.clickNoticeItem(
                      title: '${controller.newsArr[index].title}', 
                      description: '${controller.newsArr[index].description}'
                    );
                  });
                }, 
                itemCount: controller.newsArr.length
              ),
            )
          ],
        ),
      ),
    );
  }

  /// 活动Body
  Widget _activityBody(HomePageController controller) {
    return Column(
      children: controller.activitiesArr.map((item) {
        if (item.type == 1) {
          return _storeBody(item: item);
        } else if (item.type == 2) {
          return _timeLimit(item: item);
        } else if (item.type == 4) {
          return _specialArea(item: item);
        } else if (item.type == 5) {
          return _blindboxBody(item: item);
        }
        return Container();
      }).toList(),
    );
  }

  /// 超值卖场
  Widget _storeBody({required ActivitiesItem item}) {
    return Container(
      margin: EdgeInsets.only(top: 12.h),
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      child: Stack(
        children: [
          Column(
            children: [
              SizedBox(height: 43.h),
              Container(
                padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 12.h),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(5.w),
                  gradient: LinearGradient(
                    begin: Alignment.topCenter,
                    end: Alignment.bottomCenter,
                    colors: [
                      bgMainColor,
                      bgExcessiveColor
                    ]
                  )
                ),
                child: Container(
                  padding: EdgeInsets.only(top: 45.h, bottom: 5.h),
                  decoration: BoxDecoration(
                    color: bgWhiteColor,
                    borderRadius: BorderRadius.circular(5.w)
                  ),
                  child: ScrollConfigurationCommon(child: SingleChildScrollView(
                    scrollDirection: Axis.horizontal,
                    child: Row(
                      children: item.products!.asMap().keys.map((index) {
                        ProductsItem productsItem = item.products![index];
                        return _storeBodyItem(productsItem, index);
                      }).toList(),
                    ),
                  )),
                ),
              )
            ],
          ),
          Positioned(
            child: InkWellUtil.shakeProofInkWell(Image.asset(
              'assets/icons/icon_value_store.png',
              width: 343.w,
              height: 82.h,
              fit: BoxFit.cover,
            ), () {
              Get.toNamed(
                '${AppRouters.COMMON_PAGE}${AppRouters.ACTIVITY_GOOD_PAGE}',
                arguments: {
                  'title': '超值卖场',
                  'activityId': item.id
                }
              );
            })
          )
        ],
      ),
    );
  }

  /// 超值卖场产品Item
  Widget _storeBodyItem(ProductsItem productsItem, int index) {
    return InkWellUtil.shakeProofInkWell(Container(
      margin: EdgeInsets.only(right: 11.w, left: index == 0 ? 11.w : 0),
      width: 94.w,
      child: Column(
        children: [
          NetworkImageUtil(
            url: productsItem.thumbnail ?? '', 
            width: 94.w, 
            height: 94.w,
            borderRadius: 5.w,
          ),
          SizedBox(height: 2.h),
          Text(
            productsItem.title ?? '',
            overflow: TextOverflow.ellipsis,
            maxLines: 2,
            style: TextStyle(
              color: textBlackColor,
              fontSize: 12.sp
            ),
          ),
          SizedBox(height: 6.h),
          Text.rich(
            TextSpan(
              text: '¥',
              style: TextStyle(
                fontSize: 12.sp,
                color: bgMainColor,
                fontWeight: FontWeight.bold
              ),
              children: [
                TextSpan(
                  text: productsItem.price ?? '',
                  style: TextStyle(
                    fontSize: 16.sp,
                    color: bgMainColor,
                    fontWeight: FontWeight.bold
                  )
                )
              ]
            )
          )
        ],
      ),
    ), () {
      Get.toNamed(
        '${AppRouters.COMMON_PAGE}${AppRouters.GOOD_DETAIL_PAGE}',
        arguments: {
          'goodId': productsItem.id
        }
      );
    });
  }
  
  /// 限时特价
  Widget _timeLimit({required ActivitiesItem item}) {
    return Container(
      margin: EdgeInsets.only(top: 12.h),
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      child: Container(
        padding: EdgeInsets.symmetric(vertical: 12.h),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(5.w),
          // gradient: RadialGradient(
          //   radius: .1,
          //   colors: [
          //     // timeLimit1,
          //     // timeLimit2
          //     Color.fromRGBO(255, 83, 112, 1),
          //     Color.fromRGBO(255, 34, 92, 1),
          //   ]
          // ),
          gradient: LinearGradient(
            begin: Alignment.topLeft,
            end: Alignment.bottomRight,
            colors: [
              timeLimit1,
              timeLimit2
            ]
          ),
        ),
        child: Column(
          children: [
            Container(
              padding: EdgeInsets.symmetric(horizontal: 12.w),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    children: [
                      Row(
                        children: [
                          Text(
                            '限时特价',
                            style: TextStyle(
                              color: textWhiteColor,
                              fontSize: 18.sp
                            ),
                          ),
                          Container(
                            margin: EdgeInsets.symmetric(horizontal: 6.w),
                            width: 1.w,
                            color: bgWhiteColor,
                            height: 20.h,
                          )
                        ],
                      ),
                      Text(
                        '品质推荐',
                        style: TextStyle(
                          color: textWhiteColor,
                          fontSize: 14.sp
                        ),
                      )
                    ],
                  ),
                  InkWellUtil.shakeProofInkWell(Text(
                    '进入频道',
                    style: TextStyle(
                      color: textWhiteColor,
                      fontSize: 12.sp
                    ),
                  ), () {
                    Get.toNamed(
                      '${AppRouters.COMMON_PAGE}${AppRouters.ACTIVITY_GOOD_PAGE}',
                      arguments: {
                        'title': '限时特价',
                        'activityId': item.id
                      }
                    );
                  })
                ],
              ),
            ),
            SizedBox(height: 12.h),
            _timeLimitSwiper(item.products!),
          ],
        ),
      ),
    );
  }

  /// 限时特价Swiper
  Widget _timeLimitSwiper(List<ProductsItem> dataArr) {
    List<List<ProductsItem>> pageArr = [];
    List<ProductsItem> itemArr = [];
    dataArr.forEach((item) {
      if(itemArr.length == 4) {
        itemArr=[];
      }
      if(itemArr.length == 0) {
        pageArr.add(itemArr);
      }
      itemArr.add(item);
    });
    double _height = 97.w;
    if (pageArr.length >= 1 && pageArr[0].length >= 3) {
      _height = 187.w;
    }
    return Container(
      height: _height,
      child: pageArr.length <= 0 ? Container() : Swiper(
        itemBuilder: (context, index) {
          List<ProductsItem> arr = pageArr[index];
          return Wrap(
            spacing: 11.w,
            runSpacing: 10.w,
            children: arr.asMap().keys.map((productsItemIndex) {
              ProductsItem item = arr[productsItemIndex];
              return _timeLimitItem(item, productsItemIndex);
            }).toList(),
          );
        }, 
        itemCount: pageArr.length,
        loop: false,
        pagination: SwiperCustomPagination(
          builder: (BuildContext context, SwiperPluginConfig config) {
            return Container(
              alignment: Alignment.bottomCenter,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: pageArr.asMap().keys.map((index) {
                  if (index == config.activeIndex) {
                    return Container(
                      width: 18.w,
                      height: 5.w,
                      margin: EdgeInsets.symmetric(horizontal: 3.w),
                      decoration: BoxDecoration(
                        color: bgWhiteColor,
                        borderRadius: BorderRadius.circular(5.w)
                      ),
                    );
                  } else {
                    return Container(
                      width: 5.w,
                      height: 5.w,
                      margin: EdgeInsets.symmetric(horizontal: 3.w),
                      decoration: BoxDecoration(
                        color: bgSubColor,
                        borderRadius: BorderRadius.circular(5.w)
                      ),
                    );
                  }
                }).toList()
              ),
            );
          }
        ),
      ),
    );
  }

  /// 显示特价商品Item
  Widget _timeLimitItem(ProductsItem item, int productsItemIndex) {
    return InkWellUtil.shakeProofInkWell(Container(
      width: 160.w,
      height: 80.w,
      margin: EdgeInsets.only(left: productsItemIndex == 0 || productsItemIndex == 2 ? 6.w : 0),
      decoration: BoxDecoration(
        color: bgPinkColor,
        borderRadius: BorderRadius.circular(5.w)
      ),
      child: Row(
        children: [
          NetworkImageUtil(
            url: item.thumbnail ?? '', 
            width: 80.w, 
            height: 80.w,
            topLeftRadius: 5.w,
            bottomLeftRadius: 5.w,
          ),
          Expanded(child: Container(
            padding: EdgeInsets.symmetric(horizontal: 6.w),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                SizedBox(height: 10.w),
                Text(
                  item.title ?? '',
                  overflow: TextOverflow.ellipsis,
                  maxLines: 2,
                  style: TextStyle(
                    color: textBlackColor,
                    fontSize: 12.sp
                  ),
                ),
                SizedBox(height: 6.w),
                Text.rich(
                  TextSpan(
                    text: '¥',
                    style: TextStyle(
                      color: mainTextColor,
                      fontSize: 10.sp,
                      fontWeight: FontWeight.bold
                    ),
                    children: [
                      TextSpan(
                        text: item.price,
                        style: TextStyle(
                        color: mainTextColor,
                          fontSize: 12.sp,
                          fontWeight: FontWeight.bold
                        ),
                      )
                    ]
                  )
                )
              ],
            ),
          ))
        ],
      ),
    ), () {
      Get.toNamed(
        '${AppRouters.COMMON_PAGE}${AppRouters.GOOD_DETAIL_PAGE}',
        arguments: {
          'goodId': item.id
        }
      );
    });
  }

  /// 精选好物
  Widget _goodThings(HomePageController controller) {
    FeaturesListVo featuresListVo = controller.featuresListVo.value;
    return Container(
      margin: EdgeInsets.only(top: 20.h),
      child: Column(
        children: [
          featuresListVo.meta!.image == '' ? Container() : NetworkImageUtil(
            url: featuresListVo.meta!.image ?? '', 
            width: 200.w, 
            height: 23.h
          ),
          SizedBox(height: 10.h),
          CullingGoodsArr(goodsArr: featuresListVo.data!)
        ],
      ),
    );
  }

  /// 星选专区
  Widget _specialArea({required ActivitiesItem item}) {
    return InkWellUtil.shakeProofInkWell(Container(
        margin: EdgeInsets.only(top: 12.h),
        alignment: Alignment.center,
        child: NetworkImageUtil(
          url: item.image ?? '', 
          width: 351.w,
          height: 159.h,
        ),
      ), () {
        Get.toNamed('${AppRouters.COMMON_PAGE}${AppRouters.XINGXUAN_SPECIAL_PAGE}');
      }
    );
  }
  
  /// 盲盒入口
  Widget _blindboxBody({required ActivitiesItem item}) {
    return InkWellUtil.shakeProofInkWell(Container(
        margin: EdgeInsets.only(top: 12.h),
        alignment: Alignment.center,
        child: NetworkImageUtil(
          url: item.image ?? '', 
          width: 351.w,
          height: 115.h,
        ),
      ), () {
        if (commonPageController.userData.value.teamId! <= 0) {
          commonPageController.tabIndex.value = 1;
          CooperationPageController cooperationPageController = Get.put(CooperationPageController());
          cooperationPageController.invitationsDialog();
          return;
        }
        if (item.products!.length <= 0) {
          EasyLoading.showToast('盲盒异常');
          return;
        }
        Get.toNamed(
          '${AppRouters.COMMON_PAGE}${AppRouters.BLINDBOX_DETAIL_PAGE}',
          arguments: {
            'id': item.products![0].id
          }
        );
      }
    );
  }
}